<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	<title>小说信息修改</title>
	<link rel="stylesheet" href="css/css.css" type="text/css" />
	<script type="text/javascript" src="UEditor/third-party/jquery-1.10.2.min.js"></script>
  </head>
  <body>
	<%@ include file="./header.jsp" %>	
    <h3>商品修改</h3>

	<c:if test="${ novel != null }">
	<table style="width:900px; margin:0px auto;" class="table_border table_padding10">
		<tr class="tr_header">
			<td>项目</td>
			<td>内容&emsp;&emsp;&emsp;&emsp;</td>
		</tr>
		<tr>
			<td>商品名称</td>
			<td class="left">
				<input type="text" name="novelName" value="${ novel.novelName }" 
						maxlength="45" style="width:400px;">&ensp;
				<span class="msg">*</span>
			</td>
		</tr>
		<tr>
			<td>商品图片</td>
			<td class="left" style="padding:0 3px;">		<!-- 内联框架。对象goods在Service类GoodsService中生成 -->
				<iframe src="novelImageUpload?novelNumber=${ novel.novelNumber }&novelImage=${ novel.novelImage }"
					style="width:760px; height:155px; border:0;"></iframe>
			</td>
		</tr>
		<tr>
			<td>小说文件</td>
			<td class="left" style="padding:0 3px;">		<!-- 内联框架。对象goods在Servlet类GoodsAdd中生成 -->
				<iframe src="novelFileUpload.jsp"
						style="width:760px; height:155px; border:0;"></iframe>
			</td>
		</tr>
		<tr>
			<td>商品简介</td>
			<td class="left" style="width:750px;">
				<script type="text/plain" id="container" name="novelIntroduce">${ novel.novelIntroduce }</script>	<!-- 加载编辑器的容器 -->
			</td>
		</tr>
		<tr height="40">
			<td colspan="2" style="padding-left:100px; font-size:small;">			
				<input type="submit" value="提交" onclick="ajax()">
				&emsp;&emsp;
				<a href="novelInfoServlet?novelNumber=${ novel.novelNumber }">返回商品详情页</a>
			</td>
		</tr>
	</table>
  	</c:if>
	
	<div id="msg" class="msg">${ msg }</div>
	<br>
	<a href="novelListManagerServlet">返回商品列表</a>
	
	<%@ include file="./footer.jsp" %>
</body>
<script type="text/javascript">	

function ajax() {	
	
	var novelName 	= $("[name='novelName']").val();
	var novelIntroduce 		= ue.getContent();							//富文本编辑器ue中的输入内容
	
	var url = "novelEditDo?novelNumber=${ novel.novelNumber }";
	var arg = {	"novelName" : novelName,
			   	"novelIntroduce"  : novelIntroduce };							//JSON格式数据： {key:value, k2:v2}
				
	$.post(url, arg, function(data) {
		setMsg(data);
	});
}
  
function setMsg(msg) {
	
	if (msg.substring(0, 10) == "@Redirect:") {			//截取前10个字符。表示需网页转向
		var url = msg.substring(10); 					//截取第11个字符及之后的所有字符
		window.location.href = url;						//网页转向
		return;
	}
	
	$("#msg").html(msg);								//显示消息
}
</script>

<script type="text/javascript" src="UEditor/ueditor.config.js"></script>	<!-- 配置文件。可自行修改 -->
<script type="text/javascript" src="UEditor/ueditor.all.min.js"></script>	<!-- 编辑器源码文件 -->
<script type="text/javascript">
	var ue = UE.getEditor("container", {				//通过id实例化编辑器，得到的对象为ue
		autoHeightEnabled: false,						//高度不自动适应
		initialFrameHeight:300,							//初始化编辑器高度,默认320
		//initialFrameWidth:500,						//初始化编辑器宽度,默认500
	});
</script>
</html>
